package de.clue.corpus.twitter.bean;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import org.apache.commons.io.FileUtils;

public class XMLFileLister {
    
    private String homeDirectory;
    private String[] fileExtensions = {"xml"};
    private ArrayList<File> filesInDirectory = new ArrayList<File>();
    public String getHomeDirectory() {
        return homeDirectory;
    }
    public void setHomeDirectory(String homeDirectory) {
        this.homeDirectory = homeDirectory;
        initFileList();
    }
    public ArrayList<File> getFilesInDirectory() {
        return filesInDirectory;
    }
    public void setFilesInDirectory(ArrayList<File> filesInDirectory) {
        this.filesInDirectory = filesInDirectory;
    }
    
    private void initFileList() {
        Collection<File> listFiles = FileUtils.listFiles(new File(homeDirectory), fileExtensions , false);
        ArrayList<File> newList = new ArrayList<File>();    
        
        for (Iterator iterator = listFiles.iterator(); iterator.hasNext();) {
            File file = (File) iterator.next();
            newList.add(file);
            
        }
        setFilesInDirectory(newList);
        
    }
    

}
